﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using WyUnity.Data.DataAccess;

namespace WyUnity.Data.Query
{
    [Serializable]
    public class WhereFieldtoField : Where
    {
        protected string _field2;
        public WhereFieldtoField(string field1, SqlCompareOperation condition, string field2)
            : base(field1, condition, null)
        {
            _field2 = field2;
        }
        public override string ToClip(DataAccess.ParameterProvider pp)
        {
            if (_condition == SqlCompareOperation.In)
            {
                throw new DAException("字段之间的比较方法不能使用In方法");
            }
            else if (_condition == SqlCompareOperation.IsNull)
            {
                return string.Format("[{0}] is null", _field);
            }
            else
            {
                return string.Format("[{0}]{1}[{2}]", _field, OperatorToString(_condition), _field2);
            }
        }
    }
}
